package Form;

import javax.swing.JPanel;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import java.awt.Font;
import java.awt.Insets;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JButton;

import Control.CommonControls;
import Control.Job_UserRegistration_Controller;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class Job_jobRegistrationForm extends JPanel {
	private JLabel lblJobRegistration;
	private JLabel lblNewLabel;
	private JLabel lbl_userNric;
	private JLabel lblUserName;
	private JLabel lbl_userName;
	private JLabel lblJobId;
	private JLabel lbltoRegisterFor;
	private JButton btnRegister;
	private JLabel jobId; 
	
	private Job_SearchForm parser;
	private Job_UserRegistration_Controller Controller;
	
	public Job_SearchForm getParser() {
		return parser;
	}


	public void setParser(Job_SearchForm parser) {
		this.parser = parser;
	}
	
	public Job_UserRegistration_Controller getController() {
		return Controller;
	}


	public void setController(Job_UserRegistration_Controller Controller) {
		this.Controller = Controller;
	}


	public Job_jobRegistrationForm(Job_SearchForm parser) { 
		this.setParser(parser);
		this.setController(new Job_UserRegistration_Controller(this));
		
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{0, 0, 0, 0, 0, 0, 0};
		gridBagLayout.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
		gridBagLayout.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		setLayout(gridBagLayout);
		GridBagConstraints gbc_lblJobRegistration = new GridBagConstraints();
		gbc_lblJobRegistration.insets = new Insets(0, 0, 5, 5);
		gbc_lblJobRegistration.gridx = 3;
		gbc_lblJobRegistration.gridy = 0;
		add(getLblJobRegistration(), gbc_lblJobRegistration);
		GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
		gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel.gridx = 2;
		gbc_lblNewLabel.gridy = 2;
		add(getLblNewLabel(), gbc_lblNewLabel);
		GridBagConstraints gbc_lbl_userNric = new GridBagConstraints();
		gbc_lbl_userNric.anchor = GridBagConstraints.SOUTH;
		gbc_lbl_userNric.insets = new Insets(0, 0, 5, 5);
		gbc_lbl_userNric.gridx = 3;
		gbc_lbl_userNric.gridy = 2;
		add(getLbl_userNric(), gbc_lbl_userNric);
		GridBagConstraints gbc_lblUserName = new GridBagConstraints();
		gbc_lblUserName.insets = new Insets(0, 0, 5, 5);
		gbc_lblUserName.gridx = 2;
		gbc_lblUserName.gridy = 3;
		add(getLblUserName(), gbc_lblUserName);
		GridBagConstraints gbc_lbl_userName = new GridBagConstraints();
		gbc_lbl_userName.insets = new Insets(0, 0, 5, 5);
		gbc_lbl_userName.gridx = 3;
		gbc_lbl_userName.gridy = 3;
		add(getLbl_userName(), gbc_lbl_userName);
		GridBagConstraints gbc_lblJobId = new GridBagConstraints();
		gbc_lblJobId.anchor = GridBagConstraints.EAST;
		gbc_lblJobId.insets = new Insets(0, 0, 5, 5);
		gbc_lblJobId.gridx = 2;
		gbc_lblJobId.gridy = 5;
		add(getLblJobId(), gbc_lblJobId);
		GridBagConstraints gbc_jobId = new GridBagConstraints();
		gbc_jobId.insets = new Insets(0, 0, 5, 5);
		gbc_jobId.gridx = 3;
		gbc_jobId.gridy = 5;
		add(getJobId(), gbc_jobId);
		GridBagConstraints gbc_lbltoRegisterFor = new GridBagConstraints();
		gbc_lbltoRegisterFor.insets = new Insets(0, 0, 5, 5);
		gbc_lbltoRegisterFor.gridx = 2;
		gbc_lbltoRegisterFor.gridy = 6;
		add(getLbltoRegisterFor(), gbc_lbltoRegisterFor);
		GridBagConstraints gbc_btnRegister = new GridBagConstraints();
		gbc_btnRegister.insets = new Insets(0, 0, 0, 5);
		gbc_btnRegister.gridx = 3;
		gbc_btnRegister.gridy = 8;
		add(getBtnRegister(), gbc_btnRegister);
	} 
	

	public JLabel getLblJobRegistration() {
		if (lblJobRegistration == null) {
			lblJobRegistration = new JLabel("Job Registration");
			lblJobRegistration.setFont(new Font("Tahoma", Font.PLAIN, 20));
		}
		return lblJobRegistration;
	}
	public JLabel getLblNewLabel() {
		if (lblNewLabel == null) {
			lblNewLabel = new JLabel("User NRIC:");
			lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 15));
		}
		return lblNewLabel;
	}
	public JLabel getLbl_userNric() {
		if (lbl_userNric == null) {
			lbl_userNric = new JLabel(CommonControls.getUser().getNric());
		}
		return lbl_userNric;
	}
	public JLabel getLblUserName() {
		if (lblUserName == null) {
			lblUserName = new JLabel("User Name:");
			lblUserName.setFont(new Font("Tahoma", Font.PLAIN, 15));
		}
		return lblUserName;
	}
	public JLabel getLbl_userName() {
		if (lbl_userName == null) {
			lbl_userName = new JLabel(CommonControls.getUser().getName());
		}
		return lbl_userName;
	}
	public JLabel getLblJobId() {
		if (lblJobId == null) {
			lblJobId = new JLabel("Job ID:");
			lblJobId.setFont(new Font("Tahoma", Font.PLAIN, 15));
		}
		return lblJobId;
	}
	public JLabel getLbltoRegisterFor() {
		if (lbltoRegisterFor == null) {
			lbltoRegisterFor = new JLabel("(To register for)");
		}
		return lbltoRegisterFor;
	}
	public JButton getBtnRegister() {
		if (btnRegister == null) {
			btnRegister = new JButton("Register");
			btnRegister.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) { 
				Controller.createJob(); 
				JOptionPane.showMessageDialog(null, "Registration Success"); 
				}
			});
		}
		return btnRegister;
	}
	public JLabel getJobId() {
		if (jobId == null) {
			jobId = new JLabel("");
		}
		return jobId;
	}
}
